package com.triz.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.triz.common.annotation.Log;
import com.triz.common.core.controller.BaseController;
import com.triz.common.core.domain.AjaxResult;
import com.triz.common.enums.BusinessType;
import com.triz.business.domain.FunctionalAnalysis;
import com.triz.business.service.IFunctionalAnalysisService;
import com.triz.common.utils.poi.ExcelUtil;
import com.triz.common.core.page.TableDataInfo;

/**
 * 功能分析Controller
 * 
 * @author hlk
 * @date 2025-11-15
 */
@RestController
@RequestMapping("/business/functionalAnalysis")
public class FunctionalAnalysisController extends BaseController
{
    @Autowired
    private IFunctionalAnalysisService functionalAnalysisService;

    /**
     * 查询功能分析列表
     */
//    @PreAuthorize("@ss.hasPermi('business:functionalAnalysis:list')")
    @GetMapping("/list")
    public TableDataInfo list(FunctionalAnalysis functionalAnalysis)
    {
        startPage();
        List<FunctionalAnalysis> list = functionalAnalysisService.selectFunctionalAnalysisList(functionalAnalysis);
        return getDataTable(list);
    }

    /**
     * 导出功能分析列表
     */
//    @PreAuthorize("@ss.hasPermi('business:functionalAnalysis:export')")
    @Log(title = "功能分析", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FunctionalAnalysis functionalAnalysis)
    {
        List<FunctionalAnalysis> list = functionalAnalysisService.selectFunctionalAnalysisList(functionalAnalysis);
        ExcelUtil<FunctionalAnalysis> util = new ExcelUtil<FunctionalAnalysis>(FunctionalAnalysis.class);
        util.exportExcel(response, list, "功能分析数据");
    }

    /**
     * 获取功能分析详细信息
     */
//    @PreAuthorize("@ss.hasPermi('business:functionalAnalysis:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(functionalAnalysisService.selectFunctionalAnalysisById(id));
    }

    /**
     * 新增功能分析
     */
//    @PreAuthorize("@ss.hasPermi('business:functionalAnalysis:add')")
    @Log(title = "功能分析", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FunctionalAnalysis functionalAnalysis)
    {
        return toAjax(functionalAnalysisService.insertFunctionalAnalysis(functionalAnalysis));
    }

    /**
     * 修改功能分析
     */
//    @PreAuthorize("@ss.hasPermi('business:functionalAnalysis:edit')")
    @Log(title = "功能分析", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FunctionalAnalysis functionalAnalysis)
    {
        return toAjax(functionalAnalysisService.updateFunctionalAnalysis(functionalAnalysis));
    }

    /**
     * 删除功能分析
     */
//    @PreAuthorize("@ss.hasPermi('business:functionalAnalysis:remove')")
    @Log(title = "功能分析", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(functionalAnalysisService.deleteFunctionalAnalysisByIds(ids));
    }
}
